<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class DemoArticle extends Model
{
    protected $table = 'demo_articles';

    /**
     * 一对一模型----获取文章所属的作者信息
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function Author(){
        return $this->belongsTo('App\Models\DemoAuthor','author_id','id');
    }

    /**
     * 远程一对多
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function categorys()
    {
        return $this->belongsToMany('App\Models\DemoCategory','demo_article_category','article_id','category_id');
    }

}
